<template>
  <view class="myList">
    <view class="myItem">
      <view class="myBlock">
        <block>
          <view class="content" @click="jkjl()">
            <view class="mainLeft">
              <view class="leftImg">
                <image src="/static/my/donate.png"></image>
              </view>
              <text>捐款记录</text>
            </view>
            <u-icon name="arrow-right" color="#949CA8" size="29"></u-icon>
          </view>
          <view class="u-border-bottom"></view>
        </block>
        <block>
          <view class="content" @click="jwjl()">
            <view class="mainLeft">
              <view class="leftImg">
                <image src="/static/my/things.png"></image>
              </view>
              <text>捐物记录</text>
            </view>
            <u-icon name="arrow-right" color="#949CA8" size="29"></u-icon>
          </view>
          <view class="u-border-bottom"></view>
        </block>
		<block>
		  <view class="content" @click="hdjl()">
		    <view class="mainLeft">
		      <view class="leftImg">
		        <image src="/static/my/activity.png"></image>
		      </view>
		      <text>活动记录</text>
		    </view>
		    <u-icon name="arrow-right" color="#949CA8" size="29"></u-icon>
		  </view>
		  <view class="u-border-bottom"></view>
		</block>
		<block>
		  <view class="content" @click="hfjl()">
		    <view class="mainLeft">
		      <view class="leftImg">
		        <image src="/static/my/vip.png"></image>
		      </view>
		      <text>会费记录</text>
		    </view>
		    <u-icon name="arrow-right" color="#949CA8" size="29"></u-icon>
		  </view>
		  <view class="u-border-bottom"></view>
		</block>
		<block>
		  <view class="content" @click="jyjl()">
		    <view class="mainLeft">
		      <view class="leftImg">
		        <image src="/static/my/rescue.png"></image>
		      </view>
		      <text>救援记录</text>
		    </view>
		    <u-icon name="arrow-right" color="#949CA8" size="29"></u-icon>
		  </view>
		  <view class="u-border-bottom"></view>
		</block>
		<block>
		  <view class="content" @click="pxjl()">
		    <view class="mainLeft">
		      <view class="leftImg">
		        <image src="/static/my/training.png"></image>
		      </view>
		      <text>培训记录</text>
		    </view>
		    <u-icon name="arrow-right" color="#949CA8" size="29"></u-icon>
		  </view>
		  <view class="u-border-bottom"></view>
		</block>
		<block>
		  <view class="content" @click="bmjl()">
		    <view class="mainLeft">
		      <view class="leftImg">
		        <image src="/static/my/sign up.png"></image>
		      </view>
		      <text>报名记录</text>
		    </view>
		    <u-icon name="arrow-right" color="#949CA8" size="29"></u-icon>
		  </view>
		  <view class="u-border-bottom"></view>
		</block>
		
        <block v-for="(a, b) in routerList" :key="b">
          <view class="content" @click="onWebView(a)">
            <view class="mainLeft">
              <view class="leftImg">
                <image :src="a.icon"></image>
              </view>

              <text>{{ a.title }}</text>
            </view>
            <u-icon name="arrow-right" color="#949CA8" size="29"></u-icon>
          </view>

          <view class="u-border-bottom"></view>
        </block>
        <block>
          <view class="content" @click="logout()">
            <view class="mainLeft">
              <view class="leftImg">
                <image src="/static/my/quit.png"></image>
              </view>
              <text>退出</text>
            </view>
            <u-icon name="arrow-right" color="#949CA8" size="29"></u-icon>
          </view>
          <view class="u-border-bottom"></view>
        </block>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      //路由导航列表
      routerList: [
        // {
        //   icon: "/static/my/donate.png", //左侧菜单图标
        //   url: "https://app15.hzgsredcross.org.cn/Jw/JkInfo/MyListNew", //要跳转的url地址
        //   title: "捐款记录",
        // },
        // {
        //   icon: "/static/my/things.png", //左侧菜单图标
        //   url: "https://app15.hzgsredcross.org.cn/Jw/JwProjectDonate/MyListNew", //要跳转的url地址
        //   title: "捐物记录",
        // },
        // {
        //   icon: "/static/my/activity.png", //左侧菜单图标
        //   url: "https://www.redcross668.com/Users/HyActivity/MyActRecord", //要跳转的url地址
        //   title: "活动记录",
        // },
        // {
        //   icon: "/static/my/vip.png", //左侧菜单图标
        //   url: "", //要跳转的url地址
        //   title: "会费记录",
        //   tip: " ",
        // },
        // {
        //   icon: "/static/my/rescue.png", //左侧菜单图标
        //   url: "https://hzgsapp3.hzgsredcross.org.cn/Rescue/User/MyResAnswer.aspx", //要跳转的url地址
        //   title: "救援记录",
        // },
        // {
        //   icon: "/static/my/training.png", //左侧菜单图标
        //   url: "https://app22.hzgsredcross.org.cn/VideoAnswer/User/LifeGuardIndex.aspx", //要跳转的url地址
        //   title: "培训记录",
        // },
        // {
        //   icon: "/static/my/sign up.png", //左侧菜单图标
        //   url: "https://app22.hzgsredcross.org.cn/VideoAnswer/User/DonatorIndex.aspx", //要跳转的url地址
        //   title: "报名记录",
        // },
        {
          icon: "/static/my/contact us.png", //左侧菜单图标
          url: "http://www.hangzhouredcross.org/contact.html", //要跳转的url地址
          title: "联系我们",
          tip: "",
        },
        // {
        // 	icon:'/static/my/quit.png',//左侧菜单图标
        // 	local:'/pages/index/index',
        // 	title:'退出',
        // 	back:' '
        // }
      ],
    };
  },
  methods: {
    avoidLogin(url) {
      return new Promise((resolve) => {
        let userInfo = uni.getStorageSync("userInfo");
        if (!userInfo) {
          uni.navigateTo({
            url: "/pages/login/login",
          });
          return;
        }
        uni.request({
          url: "http://redcrossadmin.isaw.top/api/Login/AvoidLoginSign", //仅为示例，并非真实接口地址。
          data: {
            redirectUrl: url,
          },
          method: "POST",
          header: {
            Authorization: userInfo.token,
          },
          success: (res) => {
            if (res.data.code == 1) {
              var href =
                "https://app15.hzgsredcross.org.cn/Home/ZHHT?mobile=" +
                res.data.data.model.mobile +
                "&nickname=" +
                res.data.data.model.nickname +
                "&timestamp=" +
                res.data.data.model.timestamp +
                "&sign=" +
                res.data.data.sign +
                "&redirectUrl=" +
                url;
              //console.log(href);
              window.location.href = href;
            }
          },
        });
      }).catch((e) => {});
    },
	app22AvoidLogin(url) {
	  return new Promise((resolve) => {
	    let userInfo = uni.getStorageSync("userInfo");
	    if (!userInfo) {
	      uni.navigateTo({
	        url: "/pages/login/login",
	      });
	      return;
	    }
	    uni.request({
	      url: "http://redcrossadmin.isaw.top/api/Login/App22AvoidLoginSign", //仅为示例，并非真实接口地址。
	      data: {
	        redirectUrl: url,
	      },
	      method: "POST",
	      header: {
	        Authorization: userInfo.token,
	      },
	      success: (res) => {
	        if (res.data.code == 1) {
	          var href =
	            "http://app22.hzgsredcross.org.cn/publicInterface/HhMLogin.aspx?mobile=" +
	            res.data.data.model.mobile +
	            "&nickname=" +
	            res.data.data.model.nickname +
	            "&idCard=" +
	            res.data.data.model.idCard +
	            "&sign=" +
	            res.data.data.sign +
	            "&redirectUrl=" +
	            url;
	          //console.log(href);
	          window.location.href = href;
	        }
	      },
	    });
	  }).catch((e) => {});
	},
	bmjl(){
		this.app22AvoidLogin(
		  "https://app22.hzgsredcross.org.cn/VideoAnswer/User/DonatorIndex.aspx"
		);
	},
    jkjl() {
      this.avoidLogin("https://app15.hzgsredcross.org.cn/Jw/JkInfo/MyListNew?par=zonghe");
    },
    jwjl() {
      this.avoidLogin(
        "https://app15.hzgsredcross.org.cn/Jw/JwProjectDonate/MyListNew?par=zonghe"
      );
    },
	hdjl(){
		window.location.href = 'https://www.redcross668.com/Users/HyActivity/MyActRecord';
	},
	hfjl(){
		uni.showModal({
		  title: "提示",
		  content: "此功能暂未开放，敬请期待 ！",
		  success: function (res) {
		    if (res.confirm) {
		      console.log("用户点击确定");
		    } else if (res.cancel) {
		      console.log("用户点击取消");
		    }
		  },
		});
	},
	jyjl(){
		window.location.href = 'https://hzgsapp3.hzgsredcross.org.cn/Rescue/User/MyResAnswer.aspx';
	},
	pxjl(){
		this.app22AvoidLogin(
		  "https://app22.hzgsredcross.org.cn/VideoAnswer/User/LifeGuardIndex.aspx"
		);
	},
    logout() {
      uni.showModal({
        title: "提示",
        content: "确认退出登录？",
        success: function (res) {
          if (res.confirm) {
            uni.removeStorageSync("userInfo");
            uni.switchTab({
              url: "/pages/index/index",
            });
          } else if (res.cancel) {
          }
        },
      });
    },
    //跳转列表对应页面
    onWebView({ back, url, tip }) {
      // #ifdef  H5
      if (back) {
        uni.switchTab({
          url: "/pages/index/index",
        });
      }
      if (url) {
        window.location.href = url;
      }
      if (!url) {
        uni.showModal({
          title: "提示",
          content: "此功能暂未开放，敬请期待 ！",
          success: function (res) {
            if (res.confirm) {
              console.log("用户点击确定");
            } else if (res.cancel) {
              console.log("用户点击取消");
            }
          },
        });
      }
      // #endif
    },
  },
};
</script>

<style scoped lang="scss">
.myList {
  background: #edf0f5;
  padding-bottom: 90rpx;
  .myItem {
    width: auto;
    background: #ffffff;
    border-radius: 15rpx;
    margin: 30rpx 32rpx 66rpx 32rpx;
    .myBlock {
      padding: 0 34rpx;
      .content {
        width: 100%;
        height: 96rpx;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .mainLeft {
          width: 700rpx;
          position: relative;
          margin-left: 30rpx;
          height: 42rpx;
          .leftImg {
            position: absolute;
            margin-top: 5rpx;
            display: inline-block;
            image {
              width: 35rpx;
              height: 35rpx;
            }
          }
          text {
            padding-left: 60rpx;
            font-size: 26rpx;
            font-family: PingFang;
            font-weight: 400;
            color: #222222;
          }
        }
      }
    }
  }
}
</style>
